package com.rigsofrods.truckeditor.geometry;

import com.rigsofrods.truckeditor.transforms3D.Vec3D;

public class BoundingBox3D {
	public double minX = Double.MAX_VALUE;
	public double maxX = Double.MIN_VALUE;
	public double minY = Double.MAX_VALUE;
	public double maxY = Double.MIN_VALUE;
	public double minZ = Double.MAX_VALUE;
	public double maxZ = Double.MIN_VALUE;
	
	public BoundingBox3D() {}
	
	public void includePoint(Vec3D v){
		minX = Math.min(minX, v.x);
		maxX = Math.max(maxX, v.x);
		minY = Math.min(minY, v.y);
		maxY = Math.max(maxY, v.y);
		minZ = Math.min(minZ, v.z);
		maxZ = Math.max(maxZ, v.z);
	}
	
	public void includePoint(double x, double y, double z){
		minX = Math.min(minX, x);
		maxX = Math.max(maxX, x);
		minY = Math.min(minY, y);
		maxY = Math.max(maxY, y);
		minZ = Math.min(minZ, z);
		maxZ = Math.max(maxZ, z);
	}
	/** unused
	 * 
	 * @return Center of the bounding box
	 */
	public Vec3D getCenter(){
		return new Vec3D(0.5*(minX+maxX), 0.5*(minY+maxY), 0.5*(minZ+maxZ));
	}
}
